<%@ Register TagPrefix="uc1" TagName="JSCalendarSetup" Src="../UserControls/JSCalendarSetup.ascx" %>
<%@ Register TagPrefix="uc1" TagName="DateTimePicker" Src="../UserControls/DateTimePicker.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="MUKDetail.aspx.vb" Inherits="MIMS_WRS.Web.MUKDetail"%>
<%@ Register TagPrefix="dxwdc" Namespace="DevExpress.Web.ASPxDataControls" Assembly="DevExpress.Web.ASPxDataControls, Version=2.5.1.0, Culture=neutral, PublicKeyToken=79868b8147b5eae4" %>
<%@ Import namespace="MIMS_WRS.Web" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>Order Detail</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<LINK href="../style.css" type="text/css" rel="stylesheet">
		<script language="javascript" src="../js/common.js"></script>
		<script language="javascript">
var isOnSubmit = false;
var isAlreadyRefresh = false;

var initVarArray;

function form_onsubmit() {	
	ValidatorOnSubmit();
	isOnSubmit = true;
}

function window_onunload() {
	//click "X"?
	if (event.clientY < 0) {
		if (isOnSubmit == false && isAlreadyRefresh == false) {
		<% If RequestContext.Changed = True Then %>
			window.opener.btnRefresh.click();
		<% End If %>
		}
    }
}

function window_onbeforeunload() {
	var isChanged = false;
	var newVarArray = getFormsElementValue();
	for (i=0; i<newVarArray.length; i++)
		if (newVarArray[i] != initVarArray[i]) {
			isChanged = true;
			break;
		}
		 
	if (isChanged && isOnSubmit == false) {
		event.returnValue = "There are changes on your form.\nAre you sure you want to leave the page?";	
	}	
}

function getFormsElementValue() {
	
	var varArray = new Array();
	var inputCol = window.Form1.getElementsByTagName('input');	
	for (i=0; i<inputCol.length; i++) {
		var type = inputCol[i].type;
		if (type == "text")
			varArray[varArray.length] = inputCol[i].value;
		if (type == "radio" || type == "checkbox")
			varArray[varArray.length] = inputCol[i].checked;			
	}
	
	var areaCol = window.Form1.getElementsByTagName('area');	
	for (i=0; i<areaCol.length; i++) {
		varArray[varArray.length] = areaCol[i].outerText;		
	}
	
	var selectCol = window.Form1.getElementsByTagName('select');		
	for (i=0; i<selectCol.length; i++) {		
		varArray[varArray.length] = selectCol[i].selectedIndex;		
	}
	
	/*
	var s = "";
	for (i=0; i<varArray.length; i++)
		s += varArray[i] + ',';
	alert(s);
	*/
	return varArray;
}

function window_onload() {	
	pwDiv = window.document.getElementById('pleaseWait');
	if (pwDiv != null) {
		window.document.getElementById('pleaseWait').innerHTML = "";
		window.document.getElementById('pleaseWait').style.display = "none";	
	}	
	
	//document.getElementById
	if (document.body.childNodes[0].innerHTML.toString().indexOf("This application was created using the TRIAL version") > -1){
		document.body.childNodes[0].innerHTML = "";
	}
	
	window.document.getElementById('<%= txtReq.ClientID %>').focus();			
	
	window.Form1.onsubmit = form_onsubmit;		
	
	var txtETADate = window.document.getElementById('<%= calETADate.InputClientID %>');
	txtETADate.onchange = getWeek;
		
	initVarArray = getFormsElementValue();
}

function windowCloseAndRefresh() {
	isAlreadyRefresh = true;
	<% If RequestContext.Changed = True Then %>
			window.opener.btnRefresh.click();
	<% End If %>
	window.close();
}

function getWeek() { 
	var txtETADate = window.document.getElementById('<%= calETADate.InputClientID %>');
	
	var myDate = new Date(txtETADate.value);
	var myDay;
	
	if (isNaN(myDate))
		return false;
		
	myDay = myDate.getUTCDay();
	if (myDay == 0) {
		myDay = 7;
	}
	
	myDate.setDate(myDate.getDate() + (3 - myDay));
	
	var yearNumber = myDate.getUTCFullYear();

	var days = Math.floor( (myDate.getTime() - new Date(yearNumber, 0, 1, -6)) / 864e5 );
	var weekNumber = 1 + Math.floor(days/7);
	
	return weekNumber;
	
	var txtWeek = window.document.getElementById('<%= txtWeek.ClientID%>');
	txtWeek.value = weekNumber;
}

function setWeekText(text) {
	var txtWeek = window.document.getElementById('<%= txtWeek.ClientID%>');
	txtWeek.value = text;
}

function repChar(inChar, loop) {
	var returnValue = "";
	
	for (i=0; i<loop; i++)
		returnValue += inChar;
	return returnValue;
}

function combineSuppOrder() {
	var lblSuppOrder = window.document.getElementById('<%= lblSuppOrderNo.ClientID%>');
	var txtSupp = window.document.getElementById('<%= txtSupp.ClientID%>');
	var txtOrderNo = window.document.getElementById('<%= txtOrderNo.ClientID%>');
	lblSuppOrder.innerHTML = repChar('0', 3-txtSupp.value.length) + txtSupp.value + repChar('0', 3-txtOrderNo.value.length) + txtOrderNo.value;
}
		</script>
		<uc1:JSCalendarSetup id="JSCalendarSetup1" runat="server"></uc1:JSCalendarSetup>
	</HEAD>
	<body bottomMargin="0" onbeforeunload="window_onbeforeunload()" leftMargin="0" topMargin="0"
		scroll="no" onload="return window_onload()" rightMargin="0" onunload="window_onunload()">
		<form id="Form1" method="post" runat="server">	
			<div id="Navigator">Records navigator:
				<asp:literal id="ltrNavigator" runat="server" enableviewstate="true"></asp:literal>
			</div>
			<table class="FormTable" cellSpacing="1" cellPadding="1" width="100%" border="0">
				<tr>
					<td align="center" colSpan="2"><asp:label id="lblMessage" runat="server" cssclass="ErrorMessage">&nbsp;</asp:label></td>
				</tr>
				<tr>
					<td class="Label All" width="130">Req *</td>
					<td><asp:textbox onkeypress="KeyInputShortType(this)" id="txtReq" runat="server" columns="6" maxlength="4"></asp:textbox><asp:requiredfieldvalidator id="RequiredFieldValidator3" runat="server" errormessage="please input Req number"
							display="Dynamic" font-bold="True" controltovalidate="txtReq">!</asp:requiredfieldvalidator><asp:comparevalidator id="CompareValidator2" runat="server" errormessage="must be numeric" display="Dynamic"
							font-bold="True" controltovalidate="txtReq" type="Integer" operator="DataTypeCheck">!</asp:comparevalidator>&nbsp;
						<span class="Label All">Bulk</span>&nbsp;<asp:dropdownlist id="ddlBulk" runat="server">
							<asp:listitem value="N">New</asp:listitem>
							<asp:listitem value="F">Full</asp:listitem>
							<asp:listitem value="P">Part</asp:listitem>
						</asp:dropdownlist></td>
				</tr>
				<tr>
					<td class="Label All">Order date *</td>
					<td>
						<table class="FormTable" cellSpacing="0" cellPadding="0" border="0">
							<tr>
								<td><uc1:datetimepicker id="calOrderDate" runat="server" EnableRequiredValidator="true" RequiredErrorMessage="please input order date"
										RequiredText="!"></uc1:datetimepicker></td>
								<td></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="Label Officer">Size</td>
					<td><asp:dropdownlist id="ddlSize" runat="server">
							<asp:listitem selected="True"></asp:listitem>
							<asp:listitem value="40'">40'</asp:listitem>
							<asp:listitem value="40'HC">40'HC</asp:listitem>
							<asp:listitem value="20'">20'</asp:listitem>
							<asp:listitem value="LCL">LCL</asp:listitem>
							<asp:listitem value="Truck">Truck</asp:listitem>
						</asp:dropdownlist>&nbsp; <span class="Label Officer">Pack</span>
						<asp:dropdownlist id="ddlPack" runat="server">
							<asp:ListItem Selected="True"></asp:ListItem>
							<asp:ListItem Value="H">HD Pallet</asp:ListItem>
							<asp:ListItem Value="T">TS Pallet</asp:ListItem>
							<asp:ListItem Value="P">TD Pallet</asp:ListItem>
							<asp:ListItem Value="D">SD Pallet</asp:ListItem>
							<asp:ListItem Value="C">HC Crate</asp:ListItem>
							<asp:ListItem Value="L">Loose</asp:ListItem>
							<asp:ListItem Value="M">Mixed</asp:ListItem>
							<asp:ListItem Value="S">Samples</asp:ListItem>
						</asp:dropdownlist>&nbsp; <span class="Label All">Type *</span>&nbsp;
						<asp:dropdownlist id="ddlType" runat="server">
							<asp:ListItem Value="0">[--select--]</asp:ListItem>
							<asp:ListItem Value="W">Warehouse</asp:ListItem>
							<asp:ListItem Value="D">Direct FOB</asp:ListItem>
							<asp:ListItem Value="H">Direct HD</asp:ListItem>
						</asp:dropdownlist><asp:requiredfieldvalidator id="Requiredfieldvalidator4" runat="server" errormessage="please select order type"
							display="Dynamic" font-bold="True" controltovalidate="ddlType" initialvalue="0">!</asp:requiredfieldvalidator></td>
				</tr>
				<tr>
					<td class="Label  All">Suppiler *</td>
					<td><asp:textbox onkeypress="KeyInputShortType(this)" id="txtSupp" runat="server" columns="5" maxlength="3"
							onchange="combineSuppOrder()"></asp:textbox><asp:requiredfieldvalidator id="Requiredfieldvalidator5" runat="server" errormessage="please input Supplier number"
							display="Dynamic" font-bold="True" controltovalidate="txtSupp">!</asp:requiredfieldvalidator><asp:comparevalidator id="Comparevalidator3" runat="server" errormessage="must be numeric" display="Dynamic"
							font-bold="True" controltovalidate="txtSupp" type="Integer" operator="DataTypeCheck">!</asp:comparevalidator>&nbsp;
						<span class="Label All">Order no *</span>
						<asp:textbox onkeypress="KeyInputShortType(this)" id="txtOrderNo" runat="server" columns="5"
							maxlength="3" onchange="combineSuppOrder()"></asp:textbox><asp:comparevalidator id="Comparevalidator4" runat="server" errormessage="must be numeric" display="Dynamic"
							font-bold="True" controltovalidate="txtOrderNo" type="Integer" operator="DataTypeCheck">!</asp:comparevalidator><asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" errormessage="please input order number"
							display="Dynamic" font-bold="True" controltovalidate="txtOrderNo">!</asp:requiredfieldvalidator>&nbsp;&nbsp;<span class="Label All">Supplier 
							Order no: </span>
						<asp:label id="lblSuppOrderNo" runat="server"></asp:label></td>
				</tr>
				<tr>
					<td class="Label All">Primary</td>
					<td><asp:dropdownlist id="ddlPrimary" runat="server">
							<asp:ListItem Selected="True"></asp:ListItem>
							<asp:ListItem Value="P">Primary</asp:ListItem>
							<asp:ListItem Value="S">Secondary</asp:ListItem>
							<asp:ListItem Value="T">Combined</asp:ListItem>
							<asp:ListItem Value="U">B Combined</asp:ListItem>
						</asp:dropdownlist></td>
				</tr>
				<tr>
					<td class="Label All">Consolidation</td>
					<td>
						<table class="FormTable" cellSpacing="0" cellPadding="0" border="0">
							<tr>
								<td><asp:textbox onkeypress="KeyInputShortType(this)" id="txtCon" runat="server" columns="3" maxlength="1"></asp:textbox><asp:comparevalidator id="Comparevalidator5" runat="server" errormessage="must be numeric" display="Dynamic"
										font-bold="True" controltovalidate="txtCon" type="Integer" operator="DataTypeCheck">!</asp:comparevalidator>&nbsp;
								</td>
								<td class="Label Officer">Catalogue</td>
								<td><asp:TextBox ID="txtCatalogue" Runat="server" MaxLength="9" Columns="12"></asp:TextBox></td>
								<td class="Label All">PO In Opera</td>
								<td><uc1:datetimepicker id="calPOInOpera" runat="server" EnableRequiredValidator="false" RequiredText="!"></uc1:datetimepicker></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="Label  Officer">
						PI/SC</td>
					<td>
						<asp:textbox id="txtPISC" runat="server" maxlength="12" columns="20"></asp:textbox>&nbsp;<SPAN class="Label Officer">Account 
							no</SPAN>
						<asp:textbox id="txtAccNo" runat="server" maxlength="7" columns="9"></asp:textbox></td>
				</tr>
				<TR>
					<TD class="Label Officer">Customer</TD>
					<TD><asp:textbox id="txtCustomer" runat="server" columns="45" maxlength="30"></asp:textbox>&nbsp;<SPAN class="Label Officer">Customer 
							PO No</SPAN>
						<asp:textbox id="txtCustPONo" runat="server" columns="17" maxlength="12"></asp:textbox></TD>
				</TR>
				<tr>
					<td class="Label Officer">Final Destination</td>
					<td><asp:textbox id="txtFinalDestination" runat="server" columns="45" maxlength="30"></asp:textbox></td>
				</tr>
				<tr>
					<td class="Label Officer">Arrival Port</td>
					<td><asp:textbox id="txtArrivalPort" runat="server" columns="45" maxlength="30"></asp:textbox></td>
				</tr>
				<tr>
					<td class="Label  All">Description</td>
					<td><asp:textbox id="txtDescription" runat="server" columns="85" maxlength="50"></asp:textbox></td>
				</tr>
				<tr>
					<td class="Label Supplier">Factory ETD</td>
					<td noWrap>
						<table class="FormTable" cellSpacing="0" cellPadding="0" border="0">
							<tr>
								<td><uc1:datetimepicker id="calFactoryETD" runat="server" EnableRequiredValidator="false" RequiredText="!"></uc1:datetimepicker></td>
								<td class="Label Supplier"><asp:checkbox id="chkOnHold" runat="server"></asp:checkbox></td>
								<td class="Label Supplier">On Hold&nbsp;</td>
								<td class="Label Supplier">&nbsp;&nbsp;Shipped Date&nbsp;</td>
								<td><uc1:datetimepicker id="calShippedDate" runat="server" EnableRequiredValidator="false" RequiredText="!"></uc1:datetimepicker></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="Label Supplier">Shipping Line</td>
					<td><asp:dropdownlist id="ddlSL" runat="server">
							<asp:listitem></asp:listitem>
							<asp:listitem value="KN">K&amp;N</asp:listitem>
							<asp:listitem value="NYK">NYK</asp:listitem>
							<asp:listitem value="Primecargo">Primecargo</asp:listitem>
							<asp:listitem value="Maersk">Maersk</asp:listitem>
							<asp:listitem value="MacAndrews">MacAndrews</asp:listitem>
						</asp:dropdownlist>&nbsp;&nbsp;<span class="Label Supplier">Code</span><asp:TextBox ID="txtSLCode" Runat="server" Columns="20" MaxLength="20"></asp:TextBox>&nbsp;<span class="Label Supplier">Url</span><asp:TextBox ID="txtSLUrl" Runat="server" Columns="30"></asp:TextBox>
					</td>
				</tr>
				<tr>
					<td class="Label Supplier">Vessel</td>
					<td><asp:textbox id="txtVessel" runat="server" columns="45" maxlength="30"></asp:textbox>&nbsp;
						<span class="Label Supplier">Container No</span>&nbsp;<asp:textbox id="txtContainerNo" runat="server" columns="20" maxlength="16"></asp:textbox></td>
				</tr>
				<tr>
					<td class="Label Supplier">ETA Date</td>
					<td>
						<table class="FormTable" cellSpacing="0" cellPadding="0" border="0">
							<tr>
								<td><uc1:datetimepicker id="calETADate" runat="server" EnableRequiredValidator="false" RequiredText="!"></uc1:datetimepicker></td>
								<td>&nbsp; <span class="Label Supplier">Week</span>&nbsp;</td>
								<td><asp:textbox id="txtWeek" runat="server" columns="2" readonly="True" enabled="False"></asp:textbox></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="Label Supplier">Container Delivered
					</td>
					<td><uc1:datetimepicker id="calConDel" runat="server" EnableRequiredValidator="false" RequiredText="!"></uc1:datetimepicker></td>
				</tr>
				<tr>
					<td class="Label Officer"><SPAN class="Label Officer">Pay Auth</SPAN></td>
					<td>
						<% if MIMS_WRS.Web.Security.IsAdmin then %>
						<asp:dropdownlist id="ddlPayAuth" runat="server">
							<asp:listitem selected="True"></asp:listitem>
							<asp:listitem value="MM">MM</asp:listitem>
							<asp:listitem value="AC">AC</asp:listitem>
							<asp:listitem value="AM">AM</asp:listitem>
						</asp:dropdownlist>&nbsp;<SPAN class="Label Officer">P Payment</SPAN>
						<asp:dropdownlist id="ddlPayment" runat="server">
							<asp:listitem selected="True"></asp:listitem>
							<asp:listitem value="D">Deposit Paid</asp:listitem>
							<asp:listitem value="F">Full Paid</asp:listitem>
							<asp:listitem value="R">L/C Raised</asp:listitem>
							<asp:listitem value="P">L/C Paid</asp:listitem>
							<asp:listitem value="C">Credit</asp:listitem>
						</asp:dropdownlist>
						<% end if %>
					</td>
				</tr>
				<tr>
					<td class="Label Officer"><SPAN class="Label Officer">P Inv Value</SPAN></td>
					<td>
						<asp:textbox onkeypress="NumberOnly(1)" id="txtInvValue" runat="server" columns="12" maxlength="8"></asp:textbox><asp:comparevalidator id="CompareValidator6" runat="server" errormessage="invalid Inv Value number format"
							display="Dynamic" font-bold="True" controltovalidate="txtInvValue" type="Currency" operator="DataTypeCheck">!</asp:comparevalidator>&nbsp;
						<span class="Label Officer">S Invoiced No</span><asp:textbox onkeypress="NumberOnly(0)" id="txtSInvoiced" runat="server" columns="7" maxlength="5"></asp:textbox>
						<asp:comparevalidator id="Comparevalidator7" runat="server" errormessage="invalid S Invoiced number format"
							display="Dynamic" font-bold="True" controltovalidate="txtSInvoiced" type="Integer" operator="DataTypeCheck">!</asp:comparevalidator>&nbsp;<SPAN class="Label Officer">S 
							Invoiced Pd</SPAN>
						<uc1:datetimepicker id="calSInvoicedPd" runat="server" RequiredText="!" EnableRequiredValidator="false"></uc1:datetimepicker></td>
				</tr>
				<TR>
					<TD class="Label Officer">P Pay Date</TD>
					<td><uc1:datetimepicker id="calPPayDate" runat="server" EnableRequiredValidator="false" RequiredText="!"></uc1:datetimepicker></td>
				</TR>
				<tr>
					<td class="Label Officer">Doc Received</td>
					<td><asp:checkbox id="chkDocRec" runat="server" text="Yes"></asp:checkbox></td>
				</tr>
				<tr>
					<td class="Label Officer">Completed Date</td>
					<td><uc1:datetimepicker id="calCompletedDate" runat="server" EnableRequiredValidator="false" RequiredText="!"></uc1:datetimepicker></td>
				</tr>
				<tr>
					<td class="Label Officer" height="50"></td>
					<td height="40"><asp:button id="btnSubmit" runat="server" text="Submit"></asp:button>&nbsp;<input onclick="windowCloseAndRefresh();" type="button" value="Cancel"></td>
				</tr>
			</table>
			<table cellSpacing="0" cellPadding="0" border="0">
				<tr>
					<td>&nbsp;&nbsp;</td>
					<td class="gridItem">Field Indicators:&nbsp;</td>
					<td class="gridColumnAll"><b>All&nbsp;&nbsp;</b></td>
					<td class="gridColumnOfficer"><b>Office&nbsp;&nbsp;</b></td>
					<td class="gridColumnSupplier"><b>Factory</b></td>
				</tr>
				<tr>
					<td>&nbsp;&nbsp;</td>
					<td class="txtSmall" colSpan="4"><i>* denotes a required field</i></td>
				</tr>
			</table>
			<asp:validationsummary id="ValidationSummary1" runat="server" showmessagebox="True" showsummary="False"></asp:validationsummary></form>
	</body>
</HTML>
